import Vue from 'vue'
import axios from 'axios';
import VueAxios from 'vue-axios';
import Qs from 'qs';
import VueCookie from "vue-cookie";

Vue.use(VueAxios, axios);

// 添加请求拦截器
axios.interceptors.request.use(function (config) {
    config.headers['Accept'] = 'application/json';
    const token = VueCookie.get('token');
    if(token){
        config.headers['Authorization'] = 'Bearer ' + token;
    }
    return config;
}, function (error) {
    return Promise.reject(error);
});

// 添加响应拦截器
axios.interceptors.response.use(function (response) {
    // 对响应数据做点什么

    return response.data;
}, function (error) {
    // 对响应错误做点什么
    return Promise.reject(error);
});

// 定义基础路由
let base = '/admin';

// 大驼峰命名请求方法名称
//登录
export const Captcha = params => { return axios.get(`${base}/captcha`, params).then(res => res)};
export const UserLogin = params => { return axios.post(`${base}/login`, Qs.stringify(params)).then(res => res)};
//主页
export const Main = params => { return axios.get(`${base}/main`, params).then(res => res)};
//管理人员
export const ManagerList = params => { return axios.get(`${base}/manager`, params).then(res => res)};//列表
export const ManagerUpdate = params => { return axios.post(`${base}/manager/update`, Qs.stringify(params)).then(res => res)};//更新
export const ManagerDestroy = params => { return axios.post(`${base}/manager/destroy`, Qs.stringify(params)).then(res => res)};//删除
export const ManagerLock = params => { return axios.post(`${base}/manager/lock`, Qs.stringify(params)).then(res => res)};//锁定
export const ManagerActive = params => { return axios.post(`${base}/manager/active`, Qs.stringify(params)).then(res => res)};//激活
//登录日志
export const LoginLog = params => { return axios.get(`${base}/log`, params).then(res => res)};//列表
//角色管理
export const RoleList = params => { return axios.get(`${base}/role`, params).then(res => res)};//列表
export const RoleUpdate = params => { return axios.post(`${base}/role/update`, Qs.stringify(params)).then(res => res)};//更新
export const RoleDestroy = params => { return axios.post(`${base}/role/destroy`, Qs.stringify(params)).then(res => res)};//删除
export const RoleLock = params => { return axios.post(`${base}/role/lock`, Qs.stringify(params)).then(res => res)};//锁定
export const RoleActive = params => { return axios.post(`${base}/role/active`, Qs.stringify(params)).then(res => res)};//激活
export const RoleAll = params => { return axios.post(`${base}/role/all`, Qs.stringify(params)).then(res => res)};//所有角色
export const RoleAccess = params => { return axios.post(`${base}/access/update`, Qs.stringify(params)).then(res => res)};//权限
//推文管理
export const ArticleList = params => { return axios.get(`${base}/article`, params).then(res => res)};//列表
export const ArticleInfo = params => { return axios.get(`${base}/article/info`, params).then(res => res)};//详情
export const ArticleUpdate = params => { return axios.post(`${base}/article/update`, Qs.stringify(params)).then(res => res)};//更新
export const ArticleDestroy = params => { return axios.post(`${base}/article/destroy`, Qs.stringify(params)).then(res => res)};//删除
export const ArticleCategoryList = params => { return axios.get(`${base}/article/category`, params).then(res => res)};//类目列表
export const ArticleCategoryAll = params => { return axios.get(`${base}/article/category/all`, params).then(res => res)};//所有类目
export const ArticleCategoryUpdate = params => { return axios.post(`${base}/article/category/update`, Qs.stringify(params)).then(res => res)};//类目更新
export const ArticleCategoryDestroy = params => { return axios.post(`${base}/article/category/destroy`, Qs.stringify(params)).then(res => res)};//类目删除
//单页管理
export const PageList = params => { return axios.get(`${base}/page`, params).then(res => res)};//列表
export const PageInfo = params => { return axios.get(`${base}/page/info`, params).then(res => res)};//详情
export const PageUpdate = params => { return axios.post(`${base}/page/update`, Qs.stringify(params)).then(res => res)};//更新
export const PageDestroy = params => { return axios.post(`${base}/page/destroy`, Qs.stringify(params)).then(res => res)};//删除
//广告管理
export const AdsenseList = params => { return axios.get(`${base}/adsense`, params).then(res => res)};//列表
export const AdsenseUpdate = params => { return axios.post(`${base}/adsense/update`, Qs.stringify(params)).then(res => res)};//更新
export const AdsenseDestroy = params => { return axios.post(`${base}/adsense/destroy`, Qs.stringify(params)).then(res => res)};//删除
export const AdsenseLock = params => { return axios.post(`${base}/adsense/lock`, Qs.stringify(params)).then(res => res)};//锁定
export const AdsenseActive = params => { return axios.post(`${base}/adsense/active`, Qs.stringify(params)).then(res => res)};//激活
//合作商管理
export const PartnerList = params => { return axios.get(`${base}/partner`, params).then(res => res)};//列表
export const PartnerUpdate = params => { return axios.post(`${base}/partner/update`, Qs.stringify(params)).then(res => res)};//更新
export const PartnerDestroy = params => { return axios.post(`${base}/partner/destroy`, Qs.stringify(params)).then(res => res)};//删除
export const PartnerLock = params => { return axios.post(`${base}/partner/lock`, Qs.stringify(params)).then(res => res)};//锁定
export const PartnerActive = params => { return axios.post(`${base}/partner/active`, Qs.stringify(params)).then(res => res)};//激活
//会员管理
export const UserList = params => { return axios.get(`${base}/user`, params).then(res => res)};//列表
export const UserAgent = params => { return axios.get(`${base}/user/agent`, params).then(res => res)};//代理
//会员等级
export const LevelList = params => { return axios.get(`${base}/level`, params).then(res => res)};//列表
export const LevelUpdate = params => { return axios.post(`${base}/level/update`, Qs.stringify(params)).then(res => res)};//更新
export const LevelDestroy = params => { return axios.post(`${base}/level/destroy`, Qs.stringify(params)).then(res => res)};//删除
export const LevelAll = params => { return axios.post(`${base}/level/all`, Qs.stringify(params)).then(res => res)};//所有
//提现管理
export const CashList = params => { return axios.get(`${base}/cash`, params).then(res => res)};//列表
export const CashUpdate = params => { return axios.post(`${base}/level/update`, Qs.stringify(params)).then(res => res)};//更新
//系统设置
export const ConfigList = params => { return axios.get(`${base}/config`, params).then(res => res)};//配置
export const ConfigUpdate = params => { return axios.post(`${base}/config/update`, Qs.stringify(params)).then(res => res)};//更新
//登录日志
export const IntegralList = params => { return axios.get(`${base}/integral`, params).then(res => res)};//列表
//健康档案
export const MemberList = params => { return axios.get(`${base}/member`, params).then(res => res)};//列表
// 医单云问诊工单
export const ConsultationIndex = params => { return axios.post(`${base}/consultation/index`, params).then(res => res)};//列表
export const ConsultationDel = params => { return axios.post(`${base}/consultation/destroy`, Qs.stringify(params)).then(res => res)};//删除
export const ConsultationReply = params => { return axios.post(`${base}/consultation/reply`, Qs.stringify(params)).then(res => res)};//回复
// 医单云问诊工单-对话
export const ConsultationRecordsIndex = params => { return axios.post(`${base}/consultation-records/index`, params).then(res => res)};//列表
export const ConsultationRecordsDel = params => { return axios.post(`${base}/consultation-records/destroy`, Qs.stringify(params)).then(res => res)};//删除
// 分组
export const GroupsIndex = params => { return axios.post(`${base}/groups/index`, Qs.stringify(params)).then(res => res)};//分组列表
// 化验单
export const OcrIndex = params => { return axios.post(`${base}/ocr/index`, Qs.stringify(params)).then(res => res)};//化验单
export const OcrDetail = params => { return axios.post(`${base}/ocr/detail`, Qs.stringify(params)).then(res => res)};//化验单详情
// 提现
export const CashIndex = params => { return axios.post(`${base}/cash/index`, Qs.stringify(params)).then(res => res)};//列表
export const CashAgree = params => { return axios.post(`${base}/cash/agree`, Qs.stringify(params)).then(res => res)};//同意
export const CashReject = params => { return axios.post(`${base}/cash/reject`, Qs.stringify(params)).then(res => res)};//拒绝
// 物流公司
export const ExpressCompanyIndex = params => { return axios.post(`${base}/ex-comp/index`, Qs.stringify(params)).then(res => res)};//列表
export const ExpressCompanyAdd = params => { return axios.post(`${base}/ex-comp/add`, Qs.stringify(params)).then(res => res)};//新增
export const ExpressCompanyDel = params => { return axios.post(`${base}/ex-comp/del`, Qs.stringify(params)).then(res => res)};//删除
// 科室
export const DepartmentIndex = params => { return axios.post(`${base}/department/index`, Qs.stringify(params)).then(res => res)};//列表
export const DepartmentAdd = params => { return axios.post(`${base}/department/add`, Qs.stringify(params)).then(res => res)};//新增
export const DepartmentDel = params => { return axios.post(`${base}/department/del`, Qs.stringify(params)).then(res => res)};//删除
// 专家
export const DoctorIndex = params => { return axios.post(`${base}/doctor/index`, Qs.stringify(params)).then(res => res)};//列表
export const DoctorAgree = params => { return axios.post(`${base}/doctor/agree`, Qs.stringify(params)).then(res => res)};//通过
export const DoctorReject = params => { return axios.post(`${base}/doctor/reject`, Qs.stringify(params)).then(res => res)};//拒绝
export const DoctorDel = params => { return axios.post(`${base}/doctor/del`, Qs.stringify(params)).then(res => res)};//删除
// 商品分类
export const GoodsCategoryIndex = params => { return axios.post(`${base}/gcate/index`, Qs.stringify(params)).then(res => res)};//列表
export const GoodsCategoryAdd = params => { return axios.post(`${base}/gcate/add`, Qs.stringify(params)).then(res => res)};//新增
export const GoodsCategoryDel = params => { return axios.post(`${base}/gcate/del`, Qs.stringify(params)).then(res => res)};//删除
// 商品
export const GoodsIndex = params => { return axios.post(`${base}/goods/index`, Qs.stringify(params)).then(res => res)};//列表
export const GoodsAdd = params => { return axios.post(`${base}/goods/add`, Qs.stringify(params)).then(res => res)};//新增
export const GoodsDel = params => { return axios.post(`${base}/goods/del`, Qs.stringify(params)).then(res => res)};//删除
export const GoodsStatus = params => { return axios.post(`${base}/goods/status`, Qs.stringify(params)).then(res => res)};//审核
export const GoodsRec = params => { return axios.post(`${base}/goods/rec`, Qs.stringify(params)).then(res => res)};//设置推荐状态
export const GoodsParams = params => { return axios.post(`${base}/goods/params`, Qs.stringify(params)).then(res => res)};//列表参数
// 商品评论
export const OrdersCommentIndex = params => { return axios.post(`${base}/ocm/index`, Qs.stringify(params)).then(res => res)};//列表
export const OrdersCommentDel = params => { return axios.post(`${base}/ocm/del`, Qs.stringify(params)).then(res => res)};//删除
// 订单
export const OrdersIndex = params => { return axios.post(`${base}/orders/index`, Qs.stringify(params)).then(res => res)};//列表
